﻿using System;

namespace zijian666.WebApi
{
    /// <summary>
    /// 返回值格式化器接口
    /// </summary>
    public interface IResultFormatter
    {
        /// <summary>
        /// 获取一个空的返回值
        /// </summary>
        object Empty();
        /// <summary>
        /// 获取完整自定义返回值
        /// </summary>
        /// <param name="httpStatusCode">返回状态码</param>
        /// <param name="subCode">状态子码</param>
        /// <param name="data">返回值数据</param>
        /// <param name="message">返回值消息</param>
        /// <returns></returns>
        object Custom(int httpStatusCode, string? subCode, object? data, string? message);
        /// <summary>
        /// 获取接口成功返回值
        /// </summary>
        /// <param name="data">返回值数据</param>
        /// <param name="message">返回值消息</param>
        /// <returns></returns>
        object Ok(object? data, string? message = "ok");
        /// <summary>
        /// 获取接口异常返回值
        /// </summary>
        /// <param name="ex">返回异常</param>
        /// <param name="message">返回值消息</param>
        /// <returns></returns>
        object Error(Exception ex, string? message = null);
        /// <summary>
        /// 获取接口失败返回值
        /// </summary>
        /// <param name="httpStatusCode">返回状态码</param>
        /// <param name="message">返回消息</param>
        /// <returns></returns>
        object Fail(int httpStatusCode, string? message = "fail");
        /// <summary>
        /// 获取接口失败返回值
        /// </summary>
        /// <param name="httpStatusCode">返回状态码</param>
        /// <param name="subCode">状态子码</param>
        /// <param name="message">返回消息</param>
        /// <returns></returns>
        object Fail(int httpStatusCode, string? subCode, string? message = "fail");
        /// <summary>
        /// 获取格式化转换后的返回值类型
        /// </summary>
        /// <param name="type">格式化前的类型</param>
        /// <returns></returns>
        Type GetResultType(Type type);
    }
}
